<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Grom Hellscream
 * Date: 11/2/12
 * Time: 7:48 AM
 * To change this template use File | Settings | File Templates.
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$document = JFactory::getDocument();

$model = $this->get('canbo');

$phongs = $this->get('phong');
if (count($phongs) > 1) 
    $phong = $phongs[0];
elseif (count($phongs) == 1)
    $phong = $phongs;
$donvis = $this->get('donvi');
if (count($donvis) > 1)
    $donvi = $donvis[0];
elseif (count($donvis) == 1)
    $donvi = $donvis;
$khoi = $this->get('khoi');
$huongnghiencuus = $this->get('huongnghiencuu');
$congtrinhs = $this->get('congtrinh');
$khenthuongs = $this->get('khenthuong');
$kiluats = $this->get('kiluat');
?>

<div id="crumbs">
    <div style="color: #222222;font-weight: normal;margin: 0;padding: 0">
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=vast') ?>">Trang chủ</a> »
        <span>Cơ cấu tổ chức</span> »
        <?php if (isset($khoi)): ?>        
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=donvitructhuoc&id=' . $khoi->id); ?>"><?php echo $khoi->ten ?></a> »                
        <?php endif; ?>
        <?php if (isset($donvi)): ?>
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=phongtructhuocs&id=' . $donvi->id); ?>"><?php echo $donvi->ten ?></a> »
        <?php endif; ?>
        <?php if (isset($phong)): ?>
        <span><?php echo $phong->ten; ?></span> »        
        <?php endif; ?>
        <span><?php echo $model->hoten; ?></span>
    </div>
</div>

<div id="main" class="home">

<h3 class="title green">Thông tin nhân viên: <?php echo $model->hoten; ?>       
    <?php if (JFactory::getUser()->authorise('vast.hosocanbo.edit', 'com_vast') || (JFactory::getUser()->authorise('vast.hosocanbo.edit.own', 'com_vast') && $model->nguoidung_id == JFactory::getUser()->id)): ?>
    <a href="index.php?option=com_vast&view=hosocanbo&layout=edit&id=<?php echo $model->id; ?>" style="font-size: 10px;font-style: italic;text-decoration:underline;">Cập nhật</a>
    <?php endif; ?>
</h3>
<div class="single"></div>



<table class="complex" cellpadding="2" cellspacing="0" summary="Purchase Receipt Information">


    <tbody>

        <tr>
            <th class="sect" colspan="10">Ảnh</th>
        </tr>

        <tr>
            <td colspan="10" align="center">
                <img alt="<?php echo $model->hoten; ?>"
                     src="<?= file_exists($model->anhdaidien) ? $model->anhdaidien : $this->baseurl . '/media/com_vast/images/www.vast.ac.vn.gif' ?>" width="200" height="280"/>
            </td>
        </tr>

        <tr>
            <th class="sect" colspan="10">Thông tin cơ bản</th>
        </tr>

        <tr>
            <th colspan="2" class="label">Họ và tên</th>
            <td colspan="5"><?php echo $model->hoten; ?></td>
            <th colspan="1" class="label">Ngày tạo</th>
            <td colspan="2" style="width: 15%;"><?php echo date('d/m/Y', strtotime($model->ngaytao)); ?></td>
        </tr>

        <tr>
            <th colspan="2" class="label">Tên tài khoản</th>
            <td colspan="8"><?php echo $model->taikhoandientu; ?></td>
        </tr>

        <tr>
            <th colspan="2" class="label" style="width: 15%">Nhóm sử dụng</th>
            <td colspan="5">
                <?php if (isset($model->nguoidung_id) && JFactory::getUser($model->nguoidung_id)): {
                    $groupnames = '';
                    foreach (JFactory::getUser($model->nguoidung_id)->groups as $key => $value) {
                        $db = JFactory::getDbo();
                        $db->setQuery(
                            'SELECT `title`' .
                            ' FROM `#__usergroups`' .
                            ' WHERE `id` = '. (int) $key
                        );
                        $groupnames .= $db->loadResult() . ',';                    
                    }
                    echo $groupnames;
                } 
                endif; ?>
            </td>
            <th colspan="1" class="label">Giới tính</th>
            <td colspan="2">
                <?php
                if ($model->gioitinh == 1) {
                    echo 'Nam/<s>Nữ</s>';
                } else if ($model->gioitinh == 0){
                    echo '<s>Nam</s>/Nữ';
                }
                ?>
            </td>
        </tr>

        <tr>
            <th colspan="2" class="label" style="vertical-align: top;">
                Hướng nghiên cứu<br/>
                <a href="<?php echo JRoute::_('index.php?option=com_vast&view=quanlyhuongnghiencuu&context=quanlyhuongnghiencuu&id=' . $model->id); ?>" style="font-size: 10px;font-style: italic;text-decoration:underline;">Xem thêm</a>
            </th>
            <td colspan="8">
                <?php
                $count = 1;
                if (!isset($huongnghiencuus) || is_null($huongnghiencuus) || count($huongnghiencuus) <= 0) {
                    echo 'Không có dữ liệu.';
                } else {
                    echo '<ul>';
                    foreach ($huongnghiencuus as $item) {
                        $chitiet = '<div class="chitietnghiencuu_' . $count . '" style="display:none">';
                        if (isset($item->tungay) && $item->tungay !== '')
                            $chitiet .= '&nbsp;Từ ngày: ' . date('d-m-Y', strtotime($item->tungay));
                        if (isset($item->denngay) && $item->denngay !== '')
                            $chitiet .= '<br/>&nbsp;Đến ngày: ' . date('d-m-Y', strtotime($item->denngay));
                        if (isset($item->noidung) && $item->noidung !== '')
                            $chitiet .= '<br/>&nbsp;Hướng nghiên cứu: ' . $item->noidung;
                        $chitiet .= '</div>';
                        echo '<li>';
                        echo $count . '. Từ ngày ' . date('d-m-Y', strtotime($item->tungay)) . ' đến ngày ' . date('d-m-Y', strtotime($item->denngay)) . '&nbsp;';
                        echo $chitiet;
                        echo '</li>';
                        $count++;
                    }
                    echo '</ul>';
                }
                ?>
            </td>
        </tr>

        <tr>
            <th colspan="2" class="label" style="vertical-align: top;">
                Công trình đã công bố<br/>
                <a href="<?php echo JRoute::_('index.php?option=com_vast&view=quanlycongtrinh&context=quanlycongtrinh&id=' . $model->id); ?>" style="font-size: 10px;font-style: italic;text-decoration:underline;">Xem thêm</a>
            </th>
            <td colspan="8">
                <?php
                $count = 1;
                if (!isset($congtrinhs) || is_null($congtrinhs) || count($congtrinhs) <= 0) {
                    echo 'Không có dữ liệu.';
                } else {
                    echo '<ul>';
                    foreach ($congtrinhs as $item) {
                        $chitiet = '<div class="chitiet_' . $count . '" style="display:none">';
                        if (isset($item->anpham) && $item->anpham !== '')
                            $chitiet .= '&nbsp;Ấn phẩm: ' . $item->anpham;
                        if (isset($item->sotrang) && $item->sotrang !== '')
                            $chitiet .= '<br/>&nbsp;Số trang: ' . $item->sotrang;
                        if (isset($item->coquanxuatban) && $item->coquanxuatban !== '')
                            $chitiet .= '<br/>&nbsp;Cơ quan xuất bản: ' . $item->coquanxuatban;
                        if (isset($item->namxuatban) && $item->namxuatban !== '')
                            $chitiet .= '<br/>&nbsp;Năm xuất bản: ' . $item->namxuatban;
                        $chitiet .= '</div>';
                        echo '<li>';
                        echo $count . '. ' . $item->ten . '&nbsp;';
                        echo $chitiet;
                        echo '</li>';
                        $count++;
                    }
                    echo '</ul>';
                }
                ?>
            </td>
        </tr>

        <tr>
            <th colspan="2" class="label" style="vertical-align: top;">
                Khen thưởng<br/>
                <a href="<?php echo JRoute::_('index.php?option=com_vast&view=quanlykhenthuong&context=quanlykhenthuong&id=' . $model->id); ?>" style="font-size: 10px;font-style: italic;text-decoration:underline;">Xem thêm</a>
            </th>
            <td colspan="8">
                <?php
                $count = 1;
                if (!isset($khenthuongs) || is_null($khenthuongs) || count($khenthuongs) <= 0) {
                    echo 'Không có dữ liệu.';
                } else {
                    echo '<ul>';
                    foreach ($khenthuongs as $item) {
                        $chitiet = '<div class="chitiet_' . $count . '" style="display:none">';
                        if (isset($item->lydo) && $item->lydo !== '')
                            $chitiet .= '&nbsp;Lý do: ' . $item->lydo;
                        if (isset($item->ngayquyetdinh) && $item->ngayquyetdinh !== '')
                            $chitiet .= '<br/>&nbsp;Thời gian: ' . date('d/m/Y', strtotime($item->ngayquyetdinh));
                        $chitiet .= '</div>';
                        echo '<li>';
                        echo $count . '. ' . date('d/m/Y', strtotime($item->ngayquyetdinh)) . ' người ký quyết định ' . $item->nguoikiquyetdinh . '&nbsp;';
                        echo $chitiet;
                        echo '</li>';
                        $count++;
                    }
                    echo '</ul>';
                }
                ?>
            </td>
        </tr>

        <tr>
            <th colspan="2" class="label" style="vertical-align: top;">
                Kỷ luật<br/>
                <a href="<?php echo JRoute::_('index.php?option=com_vast&view=quanlykiluat&context=quanlykiluat&id=' . $model->id); ?>" style="font-size: 10px;font-style: italic;text-decoration:underline;">Xem thêm</a>
            </th>
            <td colspan="8">
                <?php
                $count = 1;
                if (!isset($kiluats) || is_null($kiluats) || count($kiluats) <= 0) {
                    echo 'Không có dữ liệu.';
                } else {
                    echo '<ul>';
                    foreach ($kiluats as $item) {
                        $chitiet = '<div class="chitiet_' . $count . '" style="display:none">';
                        if (isset($item->hinhthuc) && $item->hinhthuc !== '')
                            $chitiet .= '&nbsp;Hình thức: ' . $item->hinhthuc;
                        if (isset($item->noidung) && $item->noidung !== '')
                            $chitiet .= '<br/>&nbsp;Mức kỉ luật: ' . $item->noidung;
                        if (isset($item->thoigian) && $item->thoigian !== '')
                            $chitiet .= '<br/>&nbsp;Thời gian: ' . date('d/m/Y', strtotime($item->thoigian));
                        $chitiet .= '</div>';
                        echo '<li>';
                        echo $count . '. ' . date('d/m/Y', strtotime($item->thoigian)) . '&nbsp;';
                        echo $chitiet;
                        echo '</li>';
                        $count++;
                    }
                    echo '</ul>';
                }
                ?>
            </td>
        </tr>

        <tr>
            <th class="sect" colspan="10">
                Sơ yếu lý lịch
            </th>
        </tr>

        <tr>
            <th colspan="2" class="label">Ngày sinh</th>
            <td colspan="8"><?php echo date('d/m/Y', strtotime($model->ngaysinh)) ?></td>
        </tr>

        <tr>
            <th colspan="2" class="label">Nơi sinh</th>
            <td colspan="8"><?php echo $model->noisinh; ?></td>
        </tr>
        
        <tr>
            <th colspan="2" class="label">Quê quán</th>
            <td colspan="8"><?php echo $model->nguyenquan; ?></td>
        </tr>

        <tr>
            <th colspan="2" class="label">Số CMTND</th>
            <td colspan="8"><?php echo $model->chungminhnhandan; ?></td>
        </tr>

        <tr>
            <th colspan="2" class="label">Ngày cấp</th>
            <td colspan="5"><?php echo date('d/m/Y', strtotime($model->ngaycap)); ?></td>
            <th colspan="1" class="label">Nơi cấp</th>
            <td colspan="2" style="width: 15%;"><?php echo $model->noicap; ?></td>
        </tr>

        <tr>
            <th colspan="2" class="label">Địa chỉ thường trú</th>
            <td colspan="8"><?php echo $model->diachihientai; ?></td>
        </tr>

        <tr>
            <th colspan="2" class="label">Điện thoại liên lạc</th>
            <td colspan="8"><?php echo $model->dienthoai; ?></td>
        </tr>

        <tr>
            <th colspan="2" class="label">Dân tộc</th>
            <td colspan="3"><?php echo $model->dantoc; ?></td>
            <th colspan="2" class="label">Tôn giáo</th>
            <td colspan="3"><?php echo $model->tongiao; ?></td>
        </tr>

        <tr>
            <th colspan="2" class="label">Ngoại ngữ</th>
            <td colspan="8"><?php echo $model->ngoaingu; ?></td>
        </tr>

        <tr>
            <th colspan="2" class="label">Học hàm
                <?php if (JFactory::getUser()->authorise('vast.hosocanbo.edit', 'com_vast') || (JFactory::getUser()->authorise('vast.hosocanbo.edit.own', 'com_vast') && $model->nguoidung_id == JFactory::getUser()->id)): ?>
                <br/>         
                <a href="<?php echo JRoute::_('index.php?option=com_vast&context=quanlyhocham&view=quanlyhocham&id=' . $model->id); ?>" style="font-size: 10px;font-style: italic;text-decoration:underline;">Cập nhật</a>                     
                <?php endif; ?>
            </th>
            <td colspan="8"><?php if (isset($model->tenhocham)) echo $model->tenhocham; ?></td>
        </tr>

        <tr>
            <th colspan="2" class="label">Học vị
                <?php if (JFactory::getUser()->authorise('vast.hosocanbo.edit', 'com_vast') || (JFactory::getUser()->authorise('vast.hosocanbo.edit.own', 'com_vast') && $model->nguoidung_id == JFactory::getUser()->id)): ?>
                <br/>                               
                <a href="<?php echo JRoute::_('index.php?option=com_vast&context=quanlyhocvi&view=quanlyhocvi&id=' . $model->id); ?>" style="font-size: 10px;font-style: italic;text-decoration:underline;">Cập nhật</a>
                <?php endif; ?>
            </th>
            <td colspan="8"><?php if (isset($model->tenhocvi)) echo $model->tenhocvi; ?></td>
        </tr>
    </tbody>

</table>
</div>
